/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.jm.financeiro.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author joao
 */
@Entity
@Table(name = "codigo_ddi", catalog = "salao", schema = "public")
public class CodigoDdi implements Serializable {

    private static final long serialVersionUID = 1L;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idDdi")
    private List<ClienteEnderecoTelefone> clienteEnderecoTelefoneList;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "codigo_ddi_id_ddi_seq")
    @SequenceGenerator(name = "codigo_ddi_id_ddi_seq", sequenceName = "codigo_ddi_id_ddi_seq", initialValue = 1, allocationSize = 1)
    @Column(name = "id_ddi")
    @JoinColumn(name = "id_ddi",
    referencedColumnName = "id_ddi",
    nullable = false, //trocar para true se for possível 0-N
    insertable = true, //trocar para true
    updatable = false)
    private Integer idDdi;
    @Basic(optional = false)
    @Column(name = "ddi", nullable = false, length = 5)
    private String ddi;
    @Column(name = "descricao", length = 20)
    private String descricao;

    public CodigoDdi() {
    }

    public CodigoDdi(Integer idDdi) {
        this.idDdi = idDdi;
    }

    public CodigoDdi(Integer idDdi, String ddi) {
        this.idDdi = idDdi;
        this.ddi = ddi;
    }

    public Integer getIdDdi() {
        return idDdi;
    }

    public void setIdDdi(Integer idDdi) {
        this.idDdi = idDdi;
    }

    public String getDdi() {
        return ddi;
    }

    public void setDdi(String ddi) {
        this.ddi = ddi;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDdi != null ? idDdi.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CodigoDdi)) {
            return false;
        }
        CodigoDdi other = (CodigoDdi) object;
        if ((this.idDdi == null && other.idDdi != null) || (this.idDdi != null && !this.idDdi.equals(other.idDdi))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.jm.financeiro.entity.CodigoDdi[ idDdi=" + idDdi + " ]";
    }

    public List<ClienteEnderecoTelefone> getClienteEnderecoTelefoneList() {
        return clienteEnderecoTelefoneList;
    }

    public void setClienteEnderecoTelefoneList(List<ClienteEnderecoTelefone> clienteEnderecoTelefoneList) {
        this.clienteEnderecoTelefoneList = clienteEnderecoTelefoneList;
    }
}
